package com.dcjt.firehotcarpad.adapter

import android.content.Context
import android.view.View
import android.widget.TextView
import com.dcjt.firehotcarpad.R
import com.dcjt.firehotcarpad.entity.SearchHistoryEntity
import com.zhy.view.flowlayout.FlowLayout
import com.zhy.view.flowlayout.TagAdapter


class FlowTagAdapter(private val context: Context, datas: List<SearchHistoryEntity?>) :
    TagAdapter<SearchHistoryEntity?>(datas) {
    private val datalist: List<SearchHistoryEntity?>
    override fun getView(
        parent: FlowLayout,
        position: Int,
        entity: SearchHistoryEntity?
    ): View {
        val tv =
            View.inflate(context, R.layout.item_flowlayout_tv, null) as TextView

         datalist.get(position).apply {
             tv.text = this?.ajdjmc +" "+ this?.ajlxmc+" "+this?.keyword
         }
        return tv
    }

    override fun getCount(): Int {
        return datalist.size
    }

    override fun onSelected(position: Int, view: View) {
        view.isSelected = true
        super.onSelected(position, view)
    }

    override fun unSelected(position: Int, view: View) {
        view.isSelected = false

        super.unSelected(position, view)
    }

    init {
        datalist = datas
    }
}